package <%= packageName %>.controller;

import <%= packageName %>.model.<%= upperFirstCamelCaseName %>;
import <%= packageName %>.service.<%= upperFirstCamelCaseName %>Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/<%= kebabCaseName %>")
public class <%= upperFirstCamelCaseName %>Controller {

    @Autowired
    private <%= upperFirstCamelCaseName %>Service <%= camelCaseName %>Service;

    @GetMapping
    public ResponseEntity<List<<%= upperFirstCamelCaseName %>>> <%= upperFirstCamelCaseName %>s() {
        return ResponseEntity.ok(<%= camelCaseName %>Service.list());
    }

    @PostMapping
    public ResponseEntity create(@RequestBody <%= upperFirstCamelCaseName %> <%= upperFirstCamelCaseName %>) {
        return ResponseEntity.ok(<%= camelCaseName %>Service.saveOrUpdate(<%= upperFirstCamelCaseName %>));
    }

    @PutMapping
    public ResponseEntity update(@RequestBody <%= upperFirstCamelCaseName %> <%= upperFirstCamelCaseName %>) {
        return ResponseEntity.ok(<%= camelCaseName %>Service.saveOrUpdate(<%= upperFirstCamelCaseName %>));
    }

    @DeleteMapping("{id}")
    public ResponseEntity delete(@PathVariable Integer id) {
        return ResponseEntity.ok(<%= camelCaseName %>Service.removeById(id));
    }
}
